package com.liveinstars.quhui.business.interest.repository.persistence;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.liveinstars.api.query.InterestQuery;
import com.liveinstars.quhui.business.interest.repository.po.InterestGroup;
import com.liveinstars.quhui.business.interest.repository.mapper.InterestGroupMapper;
import com.liveinstars.quhui.business.interest.repository.facade.IInterestGroupService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.onepiece.shipelves.common.enums.SystemExceptionEnum;
import com.onepiece.shipelves.common.exception.DatabaseException;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * <p>
 * 兴趣 服务实现类
 * </p>
 *
 * @author ting
 * @since 2020-10-16
 */
@Service
public class InterestGroupServiceImpl extends ServiceImpl<InterestGroupMapper, InterestGroup> implements IInterestGroupService {

    private final static Logger logger = LoggerFactory.getLogger(InterestGroupServiceImpl.class);

    @Override
    public IPage<InterestGroup> pageByQuery(InterestQuery query) {
        try {
            Page<InterestGroup> page = new Page<>(query.getPageNum(), query.getPageSize());
            QueryWrapper<InterestGroup> queryWrapper = constructQueryWrapperByQuery(query);
            this.page(page, queryWrapper);
            return page;
        } catch (Exception e) {
            logger.error("获取举报记录分页列表异常：{}", e.getMessage() , e);
            throw new DatabaseException(SystemExceptionEnum.MYSQL_OPERATING_ERROR);
        }
    }

    public QueryWrapper<InterestGroup> constructQueryWrapperByQuery(InterestQuery query) {
        QueryWrapper<InterestGroup> queryWrapper = new QueryWrapper<>();
        return queryWrapper;
    }
}
